//  编译ts

var ts = require('gulp-typescript'),
    tsc = require('gulp-tsc'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    tsProject = ts.createProject("tsconfig.json");
gulp = require('gulp');


gulp.task('build-ts', function() {

    return tsProject.src()
        .pipe(tsProject())
        .on('error', function(error) {
            console.error(error.toString());
            this.emit('end')
        })
        .js
        .pipe(concat("bundle.js"))
        .pipe(gulp.dest("js"))
        .pipe(uglify())
        .pipe(gulp.dest("js/dist"));
})

gulp.watch('./ts/**/*.ts', ['build-ts']);